package com.six666.medicaldevicetestingsystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.six666.medicaldevicetestingsystem.entity.SampleList;
import com.six666.medicaldevicetestingsystem.mapper.SampleList_Mapper;
import com.six666.medicaldevicetestingsystem.service.SampleList_Service;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SampleList_Service_Impl extends ServiceImpl<SampleList_Mapper, SampleList> implements SampleList_Service {
    @Override
    public  List<SampleList> get_sample_by_project_id(int project_id) {
        QueryWrapper<SampleList> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("projectid",project_id);
        return list(queryWrapper);
    }
    @Override
    public SampleList get_sample_by_id(int id) {
        QueryWrapper<SampleList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("sampleid", id);
        return getOne(queryWrapper);
    }

    @Override
    public boolean add_sample(String number, String name,String type_name, String model, String source, int project_id) {
        SampleList sample = new SampleList();
        sample.setSamplenumber(number);
        sample.setSamplename(name);
        sample.setModel(model);
        sample.setSource(source);
        sample.setProjectid(project_id);
        sample.setTypename(type_name);
        return save(sample);
    }

    @Override
    public boolean delete_sample(int id) {
        QueryWrapper<SampleList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("sampleid", id);
        return remove(queryWrapper);
    }

}
